<?php 
trait BasicTrait {
	protected $_getCachedResults = array();
	protected $_getCached = true;
	public function __get($key)
	{
// 		$action = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
		$action = 'get' . str_replace(' ', '', ucwords($key));
		if(method_exists($this, $action)){
			if($this->_getCached){
				if(empty($this->_getCachedResults[$action])){
					$result = $this->$action();
					$this->_getCachedResults[$action] = $result;
				}
				return $this->_getCachedResults[$action];
			}else{
				return $this->$action();
			}
		}
		return parent::__get($key);
	}
	
	public function clearGetCache()
	{
		$this->_getCachedResults = array();
	}
	public function setGetCachedOn()
	{
		$this->_getCached = true;
	}
	public function setGetCachedOff()
	{
		$this->_getCached = false;
	}
	
	public function loadModel($pk)
	{
		$model = $this->findByPk($pk);
		if(empty($model)){
			$className = get_class($this);
			$model = new $className;
		}
		
		return $model;
	}
}